package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldRegionMaterial;
import com.cleaningcloud.cld.service.ICldRegionMaterialService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 业态物资清单Controller
 * 
 * @author cleaningcloud
 * @date 2025-09-29
 */
@RestController
@RequestMapping("/regionMaterial")
public class CldRegionMaterialController extends BaseController
{
    @Autowired
    private ICldRegionMaterialService cldRegionMaterialService;

    /**
     * 查询业态物资清单列表
     */
    @RequiresPermissions("cld:regionMaterial:list")
    @GetMapping("/list")
    public TableDataInfo list(CldRegionMaterial cldRegionMaterial)
    {
        startPage();
        List<CldRegionMaterial> list = cldRegionMaterialService.selectCldRegionMaterialList(cldRegionMaterial);
        return getDataTable(list);
    }

    /**
     * 导出业态物资清单列表
     */
    @RequiresPermissions("cld:regionMaterial:export")
    @Log(title = "业态物资清单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldRegionMaterial cldRegionMaterial)
    {
        List<CldRegionMaterial> list = cldRegionMaterialService.selectCldRegionMaterialList(cldRegionMaterial);
        ExcelUtil<CldRegionMaterial> util = new ExcelUtil<CldRegionMaterial>(CldRegionMaterial.class);
        util.exportExcel(response, list, "业态物资清单数据");
    }

    /**
     * 获取业态物资清单详细信息
     */
    @RequiresPermissions("cld:regionMaterial:query")
    @GetMapping(value = "/{regionMaterialId}")
    public AjaxResult getInfo(@PathVariable("regionMaterialId") Long regionMaterialId)
    {
        return success(cldRegionMaterialService.selectCldRegionMaterialByRegionMaterialId(regionMaterialId));
    }

    /**
     * 新增业态物资清单
     */
    @RequiresPermissions("cld:regionMaterial:add")
    @Log(title = "业态物资清单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldRegionMaterial cldRegionMaterial)
    {
        return toAjax(cldRegionMaterialService.insertCldRegionMaterial(cldRegionMaterial));
    }

    /**
     * 修改业态物资清单
     */
    @RequiresPermissions("cld:regionMaterial:edit")
    @Log(title = "业态物资清单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldRegionMaterial cldRegionMaterial)
    {
        return toAjax(cldRegionMaterialService.updateCldRegionMaterial(cldRegionMaterial));
    }

    /**
     * 删除业态物资清单
     */
    @RequiresPermissions("cld:regionMaterial:remove")
    @Log(title = "业态物资清单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{regionMaterialIds}")
    public AjaxResult remove(@PathVariable Long[] regionMaterialIds)
    {
        return toAjax(cldRegionMaterialService.deleteCldRegionMaterialByRegionMaterialIds(regionMaterialIds));
    }
}
